var oUl = document.getElementById('wrapper').children[1].children[0];
var oInput = document.getElementsByTagName('input')[0];
var span = document.getElementsByTagName('span');

var store = creatStore({
  name: '',
  sex: 'all',
});

for (var i = 0; i < span.length; i++) {
  (function (_index) {
    span[_index].onclick = function () {
      for (var j = 0; j < span.length; j++) {
        span[j].className = 'btn';
      }
      span[_index].className = 'btn active';
      store.dispatch({ key: 'sex', value: span[_index].innerText });
    };
  })(i);
}

function update() {
  renderPage(lastFilterFunc(arr));
}
update();

store.subsribe(update);

oInput.oninput = function () {
  store.dispatch({ key: 'text', value: this.value });
};
